package com.justnow.offer;


import org.omg.CORBA.INTERNAL;

import java.util.*;

public class Wanmei02 {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //建筑物个数
        int n = Integer.parseInt(sc.nextLine());
        int[][] buildings = new int[n][3];
        for (int i = 0; i < n; i++) {
            String s = sc.nextLine();
            String[] arr = s.split(" ");
            for (int j = 0; j < arr.length; j++) {
                buildings[i][j] = Integer.parseInt(arr[j]);
            }
        }

        //获取天际线，待实现
        List<List<Integer>> skyline = getSkyline(buildings);

        //输出skyline到标准输出
        for (List<Integer> point : skyline) {
            int size = point.size();
            for (int i = 0; i < size; i++) {
                System.out.print(point.get(i));
                if (i < size-1) {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
    public static List<List<Integer>> getSkyline(int[][] buildings) {
        PriorityQueue<int[]> queue = new PriorityQueue<>(new Comparator<int[]>() {
            @Override
            public int compare(int[] a, int[] b) {
                if (a[0] == b[0]) {
                    return a[1] - b[1];
                } else {
                    return a[0] - b[0];
                }
            }
        });

        for (int[] building : buildings) {
            queue.add(new int[]{building[0], -building[2]});
            queue.add(new int[]{building[1], building[2]});
        }

        List<List<Integer>> res = new ArrayList<>();

        TreeMap<Integer, Integer> heights = new TreeMap<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });

        heights.put(0, 1);
        int left = 0, height = 0;

        while (!queue.isEmpty()) {
            int[] array = queue.remove();
            if (array[1] < 0) {
                heights.put(-array[1], heights.getOrDefault(-array[1], 0) + 1);
            } else {
                heights.put(array[1], heights.get(array[1]) - 1);
                if (heights.get(array[1]) == 0) {
                    heights.remove(array[1]);
                }
            }
            int maxHeight = heights.keySet().iterator().next();
            if (maxHeight != height) {
                left = array[0];
                height = maxHeight;
                res.add(Arrays.asList(left, height));
            }
        }
        return res;
    }
}
